const qiniu = require('qiniu')
// 创建上传凭证
const accessKey = 'PkvdKt2Khaiz42IeoN-vTTJjZ7U3ZHJ8FMf6tnHQ'    //七牛的accessKey
const secretKey = 'y2ixPnVCCgqbkRzJcCnW9gkcVGBhH8UCLaB6_lmL'    //七牛的secretKey
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
const options = {
    scope: 'xxk-im',
    returnBody: `{"key":"$(key)","size":$(fsize),"name":"$(fname)","type":"$(mimeType)"}`
}
const putPolicy = new qiniu.rs.PutPolicy(options)
const uploadToken = () => putPolicy.uploadToken(mac)

//服务器直传
const config = new qiniu.conf.Config();
config.zone = qiniu.zone.Zone_z0;//区域
config.useCdnDomain = true;

module.exports = {
    accessKey,
    secretKey,
    uploadToken,
    qiniu,
    config
}


